package com.hkts.naturalgasauthentication.base.serviceimpl;

import com.hkts.naturalgasauthentication.base.dao.CompanyDao;
import com.hkts.naturalgasauthentication.base.dao.ManagementBaseDao;
import com.hkts.naturalgasauthentication.base.dao.mapper.CompanyMapper;
import com.hkts.naturalgasauthentication.base.entity.Company;
import com.hkts.naturalgasauthentication.base.service.CompanyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
@Transactional
public class CompanyServiceIml implements CompanyService {
    @Autowired
    private CompanyDao companyDao;
    @Autowired
    private CompanyMapper companyMapper;
    @Override
    public ManagementBaseDao<Company, String> getRepository() {
        return companyDao;
    }


    @Override
    public Company save(Company entity) {

        return null;
    }

    @Override
    public Company getComPanyBycode(String code) {
        List<Company> byCompanyCode = companyDao.findByCompanyCode(code);
        if(byCompanyCode.size()>0){
            return byCompanyCode.get(0);
        }
        return null;
    }

    @Override
    public Company getById(String companyId) {
        Company company = companyMapper.selectById(companyId);
        return company;
    }
}
